#include<stdio.h>
#include<stdlib.h>
int inc(const void*a,const void*b){
    int *pa=(int *)a;
    int *pb=(int *)b;
    return *pa - *pb;
}
int main(){
    /**
    void *bsearch( const void *key,
                   const void *buf,
                   size_t num,
                   size_t size,
                   int (*compare)(const void *, const void *) );
    */
    int a[]={1,2,3,3,3,3,3};
    int key=3;
    //qsort(a,sizeof(a)/sizeof(a[0]),sizeof(a[0]),inc);
    int*pos=bsearch(&key,
                    a,
                    sizeof(a)/sizeof(a[0]),
                    sizeof(a[0]),
                    inc
                    );
    if(pos==NULL)
        puts("Not found!");
    else
        printf("find %d at pos:%d\n",key,pos-a);
    return 0;
}
